<html>
 <head>
  <link href="./leetcode-problem.css" rel="stylesheet" type="text/css">
 </head>
 <body>
  <div class="question_difficulty">
   难度：Medium
  </div>
  <div>
   <h1 class="question_title">
    462. Minimum Moves to Equal Array Elements II
   </h1>
   <p>
   </p>
   <p>
    Given a
    <b>
     non-empty
    </b>
    integer array, find the minimum number of moves required to make all array elements equal, where a move is incrementing a selected element by 1 or decrementing a selected element by 1.
   </p>
   <p>
    You may assume the array's length is at most 10,000.
   </p>
   <p>
    <b>
     Example:
    </b>
   </p>
   <pre>
<b>Input:</b>
[1,2,3]

<b>Output:</b>
2

<b>Explanation:</b>
Only two moves are needed (remember each move increments or decrements one element):

[1,2,3]  =&gt;  [2,2,3]  =&gt;  [2,2,2]
</pre>
  </div>
  <div>
   <h1 class="question_title">
    462. 最少移动次数使数组元素相等 II
   </h1>
   <p>
    给定一个非空整数数组，找到使所有数组元素相等所需的最小移动数，其中每次移动可将选定的一个元素加1或减1。 您可以假设数组的长度最多为10000。
   </p>
   <p>
    <strong>
     例如:
    </strong>
   </p>
   <pre>
<strong>输入:</strong>
[1,2,3]

<strong>输出:</strong>
2

<strong>说明：
</strong>只有两个动作是必要的（记得每一步仅可使其中一个元素加1或减1）： 

[1,2,3]  =&gt;  [2,2,3]  =&gt;  [2,2,2]
</pre>
  </div>
 </body>
</html>